package com.cn.route.md5;

public class VirtualNode<T extends Node> implements Node {

    private T pyhsicalNode;

    private int replicaIndex;

    public VirtualNode() {
    }

    public VirtualNode(T pyhsicalNode, int replicaIndex) {
        this.pyhsicalNode = pyhsicalNode;
        this.replicaIndex = replicaIndex;
    }

    @Override
    public String getKey() {
        return String.format("%s-%d", this.pyhsicalNode.getKey(), this.replicaIndex);
    }


    public T getPyhsicalNode() {
        return pyhsicalNode;
    }

    public void setPyhsicalNode(T pyhsicalNode) {
        this.pyhsicalNode = pyhsicalNode;
    }

    public int getReplicaIndex() {
        return replicaIndex;
    }

    public void setReplicaIndex(int replicaIndex) {
        this.replicaIndex = replicaIndex;
    }

    @Override
    public String toString() {
        return "VirtualNode{" +
                "pyhsicalNode=" + pyhsicalNode +
                ", replicaIndex=" + replicaIndex +
                '}';
    }
}
